//
//  EditPersonalViewController.m
//  YiqiMobile
//
//  Created by henry on 13-4-20.
//  Copyright (c) 2013年 henry. All rights reserved.
//

#import "EditPersonalViewController.h"
#import "Config.h"
#import "Utility.h"
#import "EditPersonalView0Cell.h"
#import "EditPersonalView1Cell.h"

@interface EditPersonalViewController ()

@end

@implementation EditPersonalViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
     self.navigationItem.titleView=[Utility getTitleView:@"编辑资料"];
    self.view.backgroundColor=[UIColor colorWithRed:249.0/255 green:249.0/255 blue:249.0/255 alpha:1.0];
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[Utility customButton:self action:@selector(savePersonalAction:) normalImage:@"noti_save_normal.png" lightedImage:@"noti_save_hover.png" frame:CGRectMake(0, 0, 59, 30) title:nil tag:11]];
    self.navigationItem.rightBarButtonItem=rightBarButtonItem;
    
    self.dataArray=[NSMutableArray array];
    [self.dataArray addObject:@[
     @{@"logo":@"cg_logo.png",@"content":@"上传头像"}]];
    [self.dataArray addObject:@[
     @{@"name":@"昵称",@"content":@"henrysun"},
     @{@"name":@"简介",@"content":@"隆鑫天下"},
     @{@"name":@"详细介绍",@"content":@"上传头像"},
     @{@"name":@"联系方式",@"content":@"上传头像"},
     @{@"name":@"地址",@"content":@"广州市天河区黄埔大道"}
     ]];
    float height=416;
    if (iPhone5) {
        height+=88;
    }
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,320,height) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.separatorColor=[UIColor colorWithRed:228.0/255 green:228.0/255 blue:228.0/255 alpha:1.0];
    [self.view addSubview:self.tableView];
}

-(IBAction)savePersonalAction:(id)sender{

}
#pragma mark - TableViewdelegate&&TableViewdataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        return 56;
    }else{
        return 50;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}


- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [[self.dataArray objectAtIndex:section] count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return [self.dataArray count];
}



- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary *dict=[[self.dataArray objectAtIndex:indexPath.section]  objectAtIndex:indexPath.row];
    if (indexPath.section==0) {
        static NSString *indentifier = @"editPerdonal0Cell";
        EditPersonalView0Cell *cell =(EditPersonalView0Cell*)[tableView dequeueReusableCellWithIdentifier:indentifier];
        if (!cell) {
            cell =[[EditPersonalView0Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
        }
       
        cell.label.text=[dict objectForKey:@"content"];
        cell.logo.image=[Utility imageNamed:[dict objectForKey:@"logo"]];
        return cell;
    }else{
        static NSString *indentifier = @"editPerdonal1Cell";
        EditPersonalView1Cell *cell =(EditPersonalView1Cell*)[tableView dequeueReusableCellWithIdentifier:indentifier];
        if (!cell) {
            cell =[[EditPersonalView1Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
        }
        cell.label1.text=[dict objectForKey:@"name"];
        cell.label2.text=[NSString stringWithFormat:@"%@",[dict objectForKey:@"content"]];
        return cell;
    }
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}




- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
